package com.hp.bon.sgw.threads;

import java.util.List;

import com.hp.bon.sgw.start.SpringContext;

public class Top100CacheManager extends LogCacheManager {

	private static Top100CacheManager _instance;

	public static Top100CacheManager getInstance() {
		if (_instance == null) {
			_instance = new Top100CacheManager();
			_instance.setName("Top100CacheManager");
		}
		return _instance;
	}

	@Override
	public void flush2File(Object e) {
		LOG.info("Too many Top100 Object in log buffer,lost " + e);
	}

	@Override
	protected void flush2BD(List<Object> tempList) {
		SpringContext.getInstance().getOuterDBDataService().bulkSaveToDB(tempList);
		if (LOG.isDebugEnabled()) {
			StringBuilder sb = new StringBuilder();
			sb.append(this.getName()).append(" insert into DB records num =");
			sb.append(tempList.size()).append(",time(ms)=").append(System.currentTimeMillis() - this.runTime);
			LOG.debug(sb.toString());
		}
	}

}
